#!/bin/bash

echo "🔍 检查环境..."

# 检查 Java
if command -v java &> /dev/null; then
    JAVA_VERSION=$(java -version 2>&1 | head -n 1)
    echo "✅ Java: $JAVA_VERSION"
else
    echo "❌ 未找到 Java"
fi

# 检查 Maven
if command -v mvn &> /dev/null; then
    MVN_VERSION=$(mvn -version | head -n 1)
    echo "✅ Maven: $MVN_VERSION"
else
    echo "❌ 未找到 Maven"
fi

# 检查 JAVA_HOME
if [ -n "$JAVA_HOME" ]; then
    echo "✅ JAVA_HOME: $JAVA_HOME"
else
    echo "⚠️  JAVA_HOME 未设置"
    echo ""
    echo "请设置 JAVA_HOME 环境变量，例如："
    echo "export JAVA_HOME=\$(/usr/libexec/java_home -v 17)"
fi

echo ""
echo "📋 项目结构检查..."
if [ -f "pom.xml" ]; then
    echo "✅ pom.xml 存在"
fi

if [ -d "src/main/java" ]; then
    echo "✅ Java 源代码目录存在"
fi

if [ -d "src/main/resources" ]; then
    echo "✅ 资源目录存在"
fi
